<?php
namespace Plu\qdh\Controllers\Api;


use Plu\qdh\Controllers\Api\ControllerBase;
use Plu\qdh\Services\PassportService;
use Plu\qdh\Plugins\WechatCryptPlugin;
use Plu\qdh\Services\ReportService;
use Plu\qdh\Services\OrderService;
use Plu\qdh\Services\QrService;



/**
 * @RoutePrefix("/report")
 */
class ReportController extends ControllerBase {

    /**
	 * @Get('/getReport')
	 */
    public function indexReportAction() {
        $reportService = new ReportService;
        $indexReport = $reportService->getIndexReport();
        return $this->release($indexReport);
    }

    /**
	 * @Get('/getProductReport')
	 */
    public function getProductReportAction() {
        $page = $this->request->getQuery('page', 'int', 1);
        $limit = 20;
        $offset = ($page - 1)*$limit;
        $reportService = new ReportService;
        list($count, $productRerpot) = $reportService->productRerpot($limit, $offset);
        return $this->release([
            'count' => $count,
            'items' => $productRerpot
        ]);
    }

    /**
	 * @Get('/getAllQr')
	 */
    public function getAllQrAction() {

        $service = new QrService;

        $items = $service->getAllQr();

        return $this->release($items);

    }

    /**
	 * @Get('/getCustReport')
	 */
    public function getCustReportAction() {
        $custId  = $this->request->getQuery('custId');
        $time    = $this->request->getQuery('time');
        $service = new ReportService;
        $items   = $service->getCustReport($custId, $time);
        return $this->release($items);
    }





}